{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bce94990-ced4-47e7-94d6-6e99cd18653a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def tran(x):\n",
    "    if type(x)!=list:\n",
    "        return \"输入格式错误——不是列表\"\n",
    "    elif 0 in [0 for i in range(len(x)) if type(x[i])!=list]:\n",
    "        return \"输入格式错误——不是矩阵\"\n",
    "    elif 0 in [0 for i in range(len(x)) if len(x[i])!=len(x[0])]:\n",
    "        return \"输入格式错误——不是矩阵\"\n",
    "    else:\n",
    "        result=[[x[i][j]for i in range(len(x))]for j in range(len(x[0]))]\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "85bfbd49-bd0c-4dfa-920e-9b7786d6fa69",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 2], [2, 2], [3, 3]]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tran([[1,2,3],[2,2,3]])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
